define(function(require, exports, module) {
	
	require("form");
	
	module.exports = function() {
		var row = {};
		return {
			data: {
				title:$.i18n.prop("sys.account.manager.role.title"),
				role:{
					label:$.i18n.prop("sys.account.manager.roles"),
					roles:[],
					selectors:[]
				},
				button:{
					submit: $.i18n.prop("sys.submit")
				}
			},
			methods: {
				init: function(data) {
					var me = this;
					row = data;
					this.initRoles(function() {me.loading("close");});
					return false;
				},
				initRoles:function(complete) {
					var me = this;
					$(this.$el).find("[name=id]").val(row.id);
					$.post("/api/account/roleData", {id:row.id}, function(data) {
						if(data.success) {
							me.role.roles = data.message.roles;
							me.role.selectors = data.message.selectors;
						}
						me.$nextTick(function() {
							if(typeof(complete) == "function") {
								complete();
							}
						});
					}, "json");
				},
				submit : function() {
					var form = $(this.$el).find("form");
					form.ajaxSubmit(function(data) {});
					this.closeWindow();
				},
				destroy: function() {
					
				}
			}
		}
	}
});